//
// AWS Manager - A free AWS console application demonstrating advanced concepts
// Copyright (C) 2008-2010 Sean O'Dell. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.awsmanager.common;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author Sean ODell
 */
public class EBSSnapshot {

    private String snapshotId;
    private String volumeId;
    private String status;
    private String startTime;
    private String progress;
    private String snapRegion;
    private int    durationHours;
    private String ownerID;
    private int    volumeSize;
    private String description;
    private String ownerAlias;

    /* meta data */
    private String snapname;
    private String snapdesc;
    private String snapownernamelast;
    private String snapownernamefirst;
    private String snapownerdept;
    private String volname;

    /** Creates a new instance of EBSSnapshot */
    public EBSSnapshot() {
    }

    public String getsnapshotId() {
        return snapshotId;
    }

    public void setsnapshotId(String snapshotId) {
        this.snapshotId = snapshotId;
    }

    public String getvolumeId() {
        return volumeId;
    }

    public void setvolumeId(String volumeId) {
        this.volumeId = volumeId;
    }

    public String getstatus() {
        return status;
    }

    public void setstatus(String status) {
        this.status = status;
    }

    public String getstartTime() {
        return startTime;
    }

    public void setstartTime(Calendar startTime) {
        Date startDate = startTime.getTime();
        Date currentDate = new Date();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");

        double diff = currentDate.getTime() - startDate.getTime();

        this.startTime = dateFormat.format(startDate);
        this.durationHours = (int) Math.ceil(diff / (1000 * 60 * 60));
    }

    public String getprogress() {
        return progress;
    }

    public void setprogress(String progress) {
        this.progress = progress;
    }

    public String getSnapRegion() {
        return snapRegion;
    }

    public void setSnapRegion(String snapRegion) {
        this.snapRegion = snapRegion;
    }

    public int getdurationHours() {
        return durationHours;
    }

    public String getsnapname() {
        return snapname;
    }

    public void setsnapname(String snapname) {
        this.snapname = snapname;
    }

    public String getsnapdesc() {
        return snapdesc;
    }

    public void setsnapdesc(String snapdesc) {
        this.snapdesc = snapdesc;
    }

    public String getsnapownernamelast() {
        return snapownernamelast;
    }

    public void setsnapownernamelast(String snapownernamelast) {
        this.snapownernamelast = snapownernamelast;
    }

    public String getsnapownernamefirst() {
        return snapownernamefirst;
    }

    public void setsnapownernamefirst(String snapownernamefirst) {
        this.snapownernamefirst = snapownernamefirst;
    }

    public String getsnapownerdept() {
        return snapownerdept;
    }

    public void setsnapownerdept(String snapownerdept) {
        this.snapownerdept = snapownerdept;
    }

    public String getVolname() {
        return volname;
    }

    public void setVolname(String volname) {
        this.volname = volname;
    }

    public String getownerID() {
        return ownerID;
    }

    public void setownerID(String ownerID) {
        this.ownerID = ownerID;
    }
    public String getdescription() {
        return description;
    }

    public void setdescription(String description) {
        this.description = description;
    }

    public String getownerAlias() {
        return ownerAlias;
    }

    public void setownerAlias(String ownerAlias) {
        this.ownerAlias = ownerAlias;
    }
    
    public int getvolumeSize() {
        return volumeSize;
    }

    public void setvolumeSize(String volumeSize) {
        if (volumeSize != null) {
            try {
                this.volumeSize = Integer.parseInt(volumeSize);
            } catch (Exception ex) {
                this.volumeSize = -1;
            }
        } else {
            this.volumeSize = 0;
        }
    }
}